/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package edu.fpt.stub;

import edu.fpt.entity.Customer;
import edu.fpt.session.CustomerFacadeLocal;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;

/**
 *
 * @author TuanAnh
 */
public class HotelStub {

    CustomerFacadeLocal customer = lookupCustomerFacadeLocal();
    
    public void insertCustomer(Customer cus){
        customer.create(cus);
    }
    public List<Customer> getAll(){
        return customer.findAll();
    }
    public boolean checkPass(String id){
        return customer.checkPass(id);
    }

    private CustomerFacadeLocal lookupCustomerFacadeLocal() {
        try {
            Context c = new InitialContext();
            return (CustomerFacadeLocal) c.lookup("java:global/ProjectManagementHotel/ProjectManagementHotel-ejb/CustomerFacade!edu.fpt.session.CustomerFacadeLocal");
        } catch (NamingException ne) {
            Logger.getLogger(getClass().getName()).log(Level.SEVERE, "exception caught", ne);
            throw new RuntimeException(ne);
        }
    }
}
